<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>JavaScript的数据类型和隐式转换 | Closure233</title><meta name="author" content="Closure233"><meta name="copyright" content="Closure233"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="JavaScript的数据类型和隐式转换js的数据类型js的数据类型分为两类：基本类型和引用类型，基本类型包括Boolean、Number、String、Undefined、Null、Symbol、Bigint（后两者是ES6新增的数据类型），除了基本类型外都是引用类型（Object），如Array、Date、Object、Function等 区别：原始类型和引用类型的区别在于存储位置的不同。原始">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript的数据类型和隐式转换">
<meta property="og:url" content="https://closure.gitee.io/2023/05/08/JavaScript%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%92%8C%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2/index.html">
<meta property="og:site_name" content="Closure233">
<meta property="og:description" content="JavaScript的数据类型和隐式转换js的数据类型js的数据类型分为两类：基本类型和引用类型，基本类型包括Boolean、Number、String、Undefined、Null、Symbol、Bigint（后两者是ES6新增的数据类型），除了基本类型外都是引用类型（Object），如Array、Date、Object、Function等 区别：原始类型和引用类型的区别在于存储位置的不同。原始">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://closure.gitee.io/images/avatar.gif">
<meta property="article:published_time" content="2023-05-08T03:30:00.000Z">
<meta property="article:modified_time" content="2023-08-08T05:27:48.905Z">
<meta property="article:author" content="Closure233">
<meta property="article:tag" content="js">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://closure.gitee.io/images/avatar.gif"><link rel="shortcut icon" href="/images/moss.ico"><link rel="canonical" href="https://closure.gitee.io/2023/05/08/JavaScript%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%92%8C%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: true,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'JavaScript的数据类型和隐式转换',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-08-08 13:27:48'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/images/avatar.gif" onerror="onerror=null;src='/images/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">11</div></a><a href="/tags/"><div class="headline">Tags</div><div class="length-num">6</div></a><a href="/categories/"><div class="headline">Categories</div><div class="length-num">0</div></a></div><hr/></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background: url(/images/cover/cover1.jpg)"><nav id="nav"><span id="blog-info"><a href="/" title="Closure233"><span class="site-name">Closure233</span></a></span><div id="menus"><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">JavaScript的数据类型和隐式转换</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2023-05-08T03:30:00.000Z" title="Created 2023-05-08 11:30:00">2023-05-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2023-08-08T05:27:48.905Z" title="Updated 2023-08-08 13:27:48">2023-08-08</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="JavaScript的数据类型和隐式转换"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="JavaScript的数据类型和隐式转换"><a href="#JavaScript的数据类型和隐式转换" class="headerlink" title="JavaScript的数据类型和隐式转换"></a>JavaScript的数据类型和隐式转换</h1><h2 id="js的数据类型"><a href="#js的数据类型" class="headerlink" title="js的数据类型"></a>js的数据类型</h2><p>js的数据类型分为两类：<code>基本类型</code>和<code>引用类型</code>，基本类型包括Boolean、Number、String、Undefined、Null、Symbol、Bigint（后两者是ES6新增的数据类型），除了基本类型外都是引用类型（Object），如<code>Array</code>、<code>Date</code>、<code>Object</code>、<code>Function</code>等</p>
<p>区别：原始类型和引用类型的区别在于存储位置的不同。原始类型的数据直接存储在<code>栈（stack）</code>中，引用类型存储在<code>堆（heap）</code>中。原始类型<mark>占用空间小，大小固定</mark>，属于频繁使用的数据。引用类型<mark>占用空间大，大小不固定</mark>，存入栈中会影响程序性能，解释器可以使用引用类型存在栈中的<code>指针</code>检索到堆中的引用类型数据实体。</p>
<h2 id="常见的隐式转换场景"><a href="#常见的隐式转换场景" class="headerlink" title="常见的隐式转换场景"></a>常见的隐式转换场景</h2><ul>
<li><p>if、while判断语句</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span>(value)</span><br><span class="line"><span class="keyword">while</span>(value)</span><br><span class="line"><span class="comment">// value会隐式转换为boolean</span></span><br></pre></td></tr></table></figure></li>
<li><p>宽松相等<code>==</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[] == [] <span class="comment">// false</span></span><br><span class="line">&#123;&#125; == &#123;&#125; <span class="comment">// false</span></span><br><span class="line">[] !== [] <span class="comment">// true</span></span><br></pre></td></tr></table></figure></li>
<li><p>加号<code>+</code>、减号<code>-</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> a = <span class="number">3</span> + <span class="number">4</span> - <span class="string">&#x27;2&#x27;</span> <span class="comment">// 5</span></span><br><span class="line"><span class="keyword">let</span> b = <span class="number">3</span> + <span class="number">4</span> + <span class="string">&#x27;2&#x27;</span> <span class="comment">// &#x27;72&#x27;</span></span><br><span class="line"><span class="keyword">let</span> trueValue = <span class="number">2</span> - <span class="literal">true</span> <span class="comment">// 1</span></span><br><span class="line"><span class="comment">// 加减运算符会按顺序进行计算，遇到字符串类型后会转换为字符串进行拼接</span></span><br></pre></td></tr></table></figure></li>
<li><p>调用<code>toString</code>和<code>valueOf</code>方法</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">(<span class="number">12</span>).<span class="title function_">toString</span>(); <span class="comment">// &#x27;12&#x27;</span></span><br><span class="line"><span class="string">&#x27;string&#x27;</span>.<span class="title function_">valueOf</span>(); <span class="comment">// &#x27;string&#x27;</span></span><br></pre></td></tr></table></figure></li>
<li><p>比较运算符</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">3</span> &gt; <span class="number">4</span> <span class="comment">// false</span></span><br><span class="line"><span class="string">&#x27;3&#x27;</span> &gt; <span class="number">4</span> <span class="comment">// false</span></span><br><span class="line"><span class="string">&#x27;3&#x27;</span> &gt; <span class="string">&#x27;10&#x27;</span> <span class="comment">// true</span></span><br><span class="line"><span class="comment">// 比较运算符两侧都是Number类型时，会直接比较大小；</span></span><br><span class="line"><span class="comment">// 比较运算符两侧不都是Number时，会将其转换为Number后再行比较；</span></span><br><span class="line"><span class="comment">// 比较运算符两侧都是String时，会分别比较字符串的Unicode编码大小</span></span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="String，Boolean-Number，-Object的相互转换"><a href="#String，Boolean-Number，-Object的相互转换" class="headerlink" title="String，Boolean, Number， Object的相互转换"></a>String，Boolean, Number， Object的相互转换</h2><h3 id="1-其他类型转换为String"><a href="#1-其他类型转换为String" class="headerlink" title="1. 其他类型转换为String"></a>1. 其他类型转换为String</h3><ul>
<li><p>null，转化为<code>&quot;null&quot;</code>;</p>
</li>
<li><p>undefined：转为<code>&quot;undefined&quot;</code>。</p>
</li>
<li><p>Boolean：<code>true</code>转为<code>&quot;true&quot;</code>，<code>false</code>转为<code>&quot;false&quot;</code>。</p>
</li>
<li><p>Number：<code>11</code>转为<code>&quot;11&quot;</code>，科学计数法<code>11e20</code>转为<code>&quot;1.1e+21&quot;</code>。</p>
</li>
<li><p>数组：空数组<code>[]</code>转为空字符串<code>&quot;&quot;</code>，如果数组中的元素有<code>null</code>或者<code>undefined</code>,同样当做空字符串处理，<code>[1,2,3,4]</code>转为<code>&quot;1,2,3,4&quot;</code>，相当于调用数组的join方法，将各元素用逗号<code>&quot;,&quot;</code>拼接起来。</p>
</li>
<li><p>函数：<code>function a()&#123;&#125;</code>转为字符串是<code>&quot;function a()&#123;&#125;&quot;</code>。</p>
</li>
<li><p>一般对象：相当于调用对象的toString()方法，返回的是<code>&quot;[object,object]&quot;</code>。</p>
</li>
</ul>
<h3 id="2-其他类型转换为Boolean"><a href="#2-其他类型转换为Boolean" class="headerlink" title="2. 其他类型转换为Boolean"></a>2. 其他类型转换为Boolean</h3><p>只有<code>null</code>、<code>undefined</code>、<code>0</code>、<code>false</code>、<code>NaN</code>、<code>空字符串</code>转换为Boolean后的值为false，其余情况都为true。</p>
<h3 id="3-其他类型转换为Number类型"><a href="#3-其他类型转换为Number类型" class="headerlink" title="3. 其他类型转换为Number类型"></a>3. 其他类型转换为Number类型</h3><ul>
<li>null：转为 <code>0</code>。</li>
<li>undefined：转为<code>NaN</code>。</li>
<li>Boolean：<code>true</code>转为<code>1</code>，<code>false</code>转为<code>0</code>。</li>
<li>字符串：如果是纯数字的字符串，则转为对应的数字，如<code>11</code>转为<code>&quot;11&quot;</code>，<code>&quot;1.1e+21&quot;</code>转为<code>1.1e+21</code>，<code>空字符串</code>转为<code>0</code>，其余情况则为<code>NaN</code>。</li>
<li>数组：数组首先会被转换成原始类型，即<code>primitive value</code>，得到原始类型后再根据上面的转换规则转换。</li>
<li>对象：和数组一样</li>
</ul>
<h3 id="4-对象转为其他类型-原始类型"><a href="#4-对象转为其他类型-原始类型" class="headerlink" title="4. 对象转为其他类型(原始类型)"></a>4. 对象转为其他类型(原始类型)</h3><ul>
<li>当对象转为其他原始类型时，会先调用对象的<code>valueOf()</code>方法，如果<code>valueOf()</code>方法返回的是原始类型，则直接返回这个原始类型;</li>
<li>如果<code>valueOf()</code>方法返回的是不是原始类型或者<code>valueOf()方法</code>不存在，则继续调用对象的<code>toString()</code>方法，如果<code>toString()</code>方法返回的是原始类型，则直接返回这个原始类型,如果不是原始类型，则直接报错抛出异常。</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a target="_blank" rel="noopener" href="https://gitee.com/closure233">Closure233</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="https://closure.gitee.io/2023/05/08/JavaScript%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%92%8C%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2/">https://closure.gitee.io/2023/05/08/JavaScript%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%92%8C%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/js/">js</a></div><div class="post_share"><div class="social-share" data-image="/images/avatar.gif" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/2023/05/10/JavaScript%E7%9A%84%E5%86%92%E6%B3%A1%E5%92%8C%E6%8D%95%E8%8E%B7/" title="JavaScript的冒泡和捕获"><div class="cover" style="background: url(/images/cover/cover1.jpg)"></div><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">JavaScript的冒泡和捕获</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>Related Articles</span></div><div class="relatedPosts-list"><div><a href="/2023/05/10/JavaScript%E7%9A%84%E5%86%92%E6%B3%A1%E5%92%8C%E6%8D%95%E8%8E%B7/" title="JavaScript的冒泡和捕获"><div class="cover" style="background: url(/images/cover/cover1.jpg)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-05-10</div><div class="title">JavaScript的冒泡和捕获</div></div></a></div><div><a href="/2023/05/20/JavaScript%E7%9A%84%E5%8E%9F%E5%9E%8B%E5%92%8C%E5%8E%9F%E5%9E%8B%E9%93%BE/" title="JavaScript的原型和原型链"><div class="cover" style="background: url(/images/cover/cover1.jpg)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-05-20</div><div class="title">JavaScript的原型和原型链</div></div></a></div><div><a href="/2023/07/14/JavaScript%E6%95%B0%E7%BB%84%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/" title="JavaScript数组常用方法"><div class="cover" style="background: url(/images/cover/cover1.jpg)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-14</div><div class="title">JavaScript数组常用方法</div></div></a></div><div><a href="/2023/08/04/JavaScript%E5%BC%82%E6%AD%A5%E7%BC%96%E7%A8%8B%E5%92%8CPromise/" title="JavaScript异步编程和Promise"><div class="cover" style="background: url(/images/cover/cover1.jpg)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-08-04</div><div class="title">JavaScript异步编程和Promise</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/images/avatar.gif" onerror="this.onerror=null;this.src='/images/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Closure233</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">11</div></a><a href="/tags/"><div class="headline">Tags</div><div class="length-num">6</div></a><a href="/categories/"><div class="headline">Categories</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/catfish233"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#JavaScript%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E5%92%8C%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2"><span class="toc-number">1.</span> <span class="toc-text">JavaScript的数据类型和隐式转换</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#js%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.1.</span> <span class="toc-text">js的数据类型</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E8%A7%81%E7%9A%84%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2%E5%9C%BA%E6%99%AF"><span class="toc-number">1.2.</span> <span class="toc-text">常见的隐式转换场景</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#String%EF%BC%8CBoolean-Number%EF%BC%8C-Object%E7%9A%84%E7%9B%B8%E4%BA%92%E8%BD%AC%E6%8D%A2"><span class="toc-number">1.3.</span> <span class="toc-text">String，Boolean, Number， Object的相互转换</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%85%B6%E4%BB%96%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2%E4%B8%BAString"><span class="toc-number">1.3.1.</span> <span class="toc-text">1. 其他类型转换为String</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%85%B6%E4%BB%96%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2%E4%B8%BABoolean"><span class="toc-number">1.3.2.</span> <span class="toc-text">2. 其他类型转换为Boolean</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E5%85%B6%E4%BB%96%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2%E4%B8%BANumber%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.3.3.</span> <span class="toc-text">3. 其他类型转换为Number类型</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-%E5%AF%B9%E8%B1%A1%E8%BD%AC%E4%B8%BA%E5%85%B6%E4%BB%96%E7%B1%BB%E5%9E%8B-%E5%8E%9F%E5%A7%8B%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.3.4.</span> <span class="toc-text">4. 对象转为其他类型(原始类型)</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/08/08/Axios/" title="Axios"><div style="background: url(/images/cover/cover1.jpg)"></div></a><div class="content"><a class="title" href="/2023/08/08/Axios/" title="Axios">Axios</a><time datetime="2023-08-08T03:30:00.000Z" title="Created 2023-08-08 11:30:00">2023-08-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/08/04/Ajax%E8%AF%B7%E6%B1%82/" title="AJAX请求"><div style="background: url(/images/cover/cover1.jpg)"></div></a><div class="content"><a class="title" href="/2023/08/04/Ajax%E8%AF%B7%E6%B1%82/" title="AJAX请求">AJAX请求</a><time datetime="2023-08-03T16:12:00.000Z" title="Created 2023-08-04 00:12:00">2023-08-04</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/08/04/JavaScript%E5%BC%82%E6%AD%A5%E7%BC%96%E7%A8%8B%E5%92%8CPromise/" title="JavaScript异步编程和Promise"><div style="background: url(/images/cover/cover1.jpg)"></div></a><div class="content"><a class="title" href="/2023/08/04/JavaScript%E5%BC%82%E6%AD%A5%E7%BC%96%E7%A8%8B%E5%92%8CPromise/" title="JavaScript异步编程和Promise">JavaScript异步编程和Promise</a><time datetime="2023-08-03T16:12:00.000Z" title="Created 2023-08-04 00:12:00">2023-08-04</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/07/14/JavaScript%E6%95%B0%E7%BB%84%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/" title="JavaScript数组常用方法"><div style="background: url(/images/cover/cover1.jpg)"></div></a><div class="content"><a class="title" href="/2023/07/14/JavaScript%E6%95%B0%E7%BB%84%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/" title="JavaScript数组常用方法">JavaScript数组常用方法</a><time datetime="2023-07-14T07:45:00.000Z" title="Created 2023-07-14 15:45:00">2023-07-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/06/21/%E7%AE%80%E5%8D%95%E7%9A%84CSS%E6%95%88%E6%9E%9C%E5%AE%9E%E7%8E%B0/" title="简单的CSS效果实现"><div style="background: url(/images/cover/cover1.jpg)"></div></a><div class="content"><a class="title" href="/2023/06/21/%E7%AE%80%E5%8D%95%E7%9A%84CSS%E6%95%88%E6%9E%9C%E5%AE%9E%E7%8E%B0/" title="简单的CSS效果实现">简单的CSS效果实现</a><time datetime="2023-06-21T05:30:00.000Z" title="Created 2023-06-21 13:30:00">2023-06-21</time></div></div></div></div></div></div></main><footer id="footer" style="background: url(/images/cover/cover1.jpg)"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Closure233</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="Back To Top"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>